# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

load("@coralnpu_hw//third_party/python:requirements.bzl", "requirement")

py_library(
    name = "TileLinkULInterface",
    srcs = ["TileLinkULInterface.py"],
    deps = [
        requirement("cocotb"),
        "//coralnpu_test_utils:secded_golden",
    ],
    visibility = ["//visibility:public"],
)

py_library(
    name = "rvv_type_util",
    srcs = ["rvv_type_util.py"],
    deps = [
        requirement("numpy"),
    ],
    visibility = ["//visibility:public"],
)

py_library(
    name = "spi_master",
    srcs = ["spi_master.py"],
    deps = [
        requirement("cocotb"),
        ":spi_constants",
    ],
    visibility = ["//visibility:public"],
)

py_library(
    name = "spi_constants",
    srcs = ["spi_constants.py"],
    visibility = ["//visibility:public"],
)

py_library(
    name = "secded_golden",
    srcs = ["secded_golden.py"],
    visibility = ["//visibility:public"],
)

py_library(
    name = "core_mini_axi_sim_interface",
    srcs = [
        "core_mini_axi_interface.py",
    ],
    deps = [
        requirement("cocotb"),
        requirement("numpy"),
        requirement("pyelftools"),
    ],
    visibility = [ "//visibility:public" ],
)

py_library(
    name = "sim_test_fixture",
    srcs = [
        "sim_test_fixture.py",
    ],
    deps = [
        requirement("cocotb"),
        requirement("numpy"),
        ":core_mini_axi_sim_interface",
    ],
    visibility = [ "//visibility:public" ],
)

py_library(
    name = "core_mini_axi_pyocd_gdbserver",
    srcs = [
        "core_mini_axi_pyocd_gdbserver.py",
    ],
    deps = [
        requirement("cocotb"),
        requirement("pyocd"),
        "@bazel_tools//tools/python/runfiles",
    ],
    data = [
        "//toolchain:gdb",
    ],
    visibility = ["//visibility:public"],
)

py_library(
    name = "ftdi_spi_master_lib",
    srcs = ["ftdi_spi_master.py"],
    deps = [
        requirement("pyftdi"),
        requirement("pyelftools"),
        ":spi_constants",
    ],
)

py_binary(
    name = "ftdi_spi_master",
    srcs = ["ftdi_spi_master.py"],
    deps = [
        ":ftdi_spi_master_lib",
    ],
)

py_binary(
    name = "run_matmul_test",
    srcs = ["run_matmul_test.py"],
    deps = [
        ":ftdi_spi_master_lib",
        requirement("numpy"),
        requirement("pyelftools"),
    ],
)

py_binary(
    name = "run_sram_test",
    srcs = ["run_sram_test.py"],
    deps = [
        ":ftdi_spi_master_lib",
        requirement("numpy"),
    ],
)

py_library(
    name = "axi_slave",
    srcs = ["axi_slave.py"],
    deps = [
        requirement("cocotb"),
    ],
    visibility = ["//visibility:public"],
)

py_binary(
    name = "rvv_cpp_util_header_generator",
    srcs = [
        "rvv_cpp_util_header_generator.py",
    ],
)

genrule(
    name = "rvv_cpp_util_header",
    srcs = [],
    outs = ["rvv_cpp_util.h"],
    cmd = "./$(location rvv_cpp_util_header_generator) > \"$@\"",
    tools = [":rvv_cpp_util_header_generator"],
)

cc_library(
    name = "rvv_cpp_util",
    hdrs = [":rvv_cpp_util.h"],
    visibility = ["//visibility:public"],
)